package cn.jiedh.app.meiweidk.welcome;

import android.Manifest;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.umeng.analytics.MobclickAgent;

import org.xutils.ex.HttpException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.jiedh.app.meiweidk.MainActivity;
import cn.jiedh.app.meiweidk.R;
import cn.jiedh.app.meiweidk.Utils.UI.AlertDialog;
import cn.jiedh.app.meiweidk.Utils.tool.ActivityUtil;
import cn.jiedh.app.meiweidk.Utils.tool.L;
import cn.jiedh.app.meiweidk.Utils.tool.MobileUtils;
import cn.jiedh.app.meiweidk.Utils.tool.NetworkUtils;
import cn.jiedh.app.meiweidk.Utils.tool.SPUtils;
import cn.jiedh.app.meiweidk.Utils.tool.StatusBarUtil;
import cn.jiedh.app.meiweidk.Utils.tool.UrlUtils;
import cn.jiedh.app.meiweidk.base.BaseActivity;
import cn.jiedh.app.meiweidk.login.LoginActivity;
import cn.jiedh.app.meiweidk.network.ResponseFailure;
import cn.jiedh.app.meiweidk.network.ResponseSuccess;
import cn.jiedh.app.meiweidk.response.BaseResponse;
import cn.jiedh.app.meiweidk.runtimepermissions.PermissionsManager;
import cn.jiedh.app.meiweidk.runtimepermissions.PermissionsResultAction;

/**
 * @name：
 * @author： 周毅
 * @phone： 15826080712
 * @createTime： 2017/5/24
 * @modifyTime： 2017/5/24
 * @explain：
 */

public class YinDaoAcitivity extends BaseActivity {

    @BindView(R.id.viewpager)
    ViewPager viewpager;
    List<View> views;
    ViewPagerAdapter adapter;
    LayoutInflater inflater;
    View three;
    ImageView tv_goin;
    private boolean isYJlogin = false;

    @Override
    protected void initView(View view) {
        MobclickAgent.onEvent(this, "enjoyNewbie");
        StatusBarUtil.transparencyBar(this);
        inflater = LayoutInflater.from(this);
        views = new ArrayList<>();
        adapter = new ViewPagerAdapter(views, this);
        views.add(inflater.inflate(R.layout.one, null));
        views.add(inflater.inflate(R.layout.two, null));
        three = inflater.inflate(R.layout.three, null);
        views.add(three);
        tv_goin = (ImageView) three.findViewById(R.id.imggo);
        viewpager.setAdapter(adapter);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void initData() {
        tv_goin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (SPUtils.getIsLogin()) {
                    ActivityUtil.next(activity, MainActivity.class);
                } else {
                    Bundle bundle = new Bundle();
                    bundle.putBoolean("isGoHome", true);
                    ActivityUtil.next(activity, LoginActivity.class, bundle);
                }
                finish();
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    protected int getLayoutView() {
        return R.layout.yindao;
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        try {
            System.exit(0);
        } catch (RuntimeException e) {

        }
    }


}
